﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MyTest
{
    /// <summary>
    /// Action 的摘要说明
    /// </summary>
    public class Action : ICart
    {
        private ArrayList  products = new ArrayList();

        public String Buy(Product p)
        {
            Add(p);
            return "购买:"+p.Name;
        }

        public Action()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }

        public bool Add(Product p)
        {
            products.Add(p);
            return true;
        }

        public object Find(Product p)
        {
            throw new NotImplementedException();
        }

        public bool Remove(Product p)
        {
            throw new NotImplementedException();
        }

        public string Show()
        {
            string result = "";
            foreach (Product p in products)
            {
                
                if(p is Book2)
                {
                    result += ((Book2)p).Isbn;
                }
                result += p.Show() + "<br>";
                result += p.ShowDetail();
            }
            return result;
        }

        public bool Update(Product p)
        {
            throw new NotImplementedException();
        }
    }
}
